﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HPIT.RentHouse.DTO;
using HPIT.RentHouse.IService;
using HPIT.RentHouse.Service.Entities;

namespace HPIT.RentHouse.Service
{
    public class CommunityService : ICommunityService
    {
        /// <summary>
        /// 根据区域Id获取小区
        /// </summary>
        /// <param name="regionId"></param>
        /// <returns></returns>
        public List<CommuityDTO> GetCommuities(long regionId)
        {
            var db = new RentEntity();
            var bs = new BaseService<T_Communities>(db);
            var list = bs.GetList(a => a.RegionId == regionId).Select(s => new CommuityDTO
            {
                Id = s.Id,  
                Name = s.Name,  
                RegionId = s.RegionId,
                Location = s.Location,
                Traffic = s.Traffic,    
                BuiltYear = (int)s.BuiltYear
            }).ToList();
            return list;    
        }
    }
}
